class Solution {
public:
    int minSetSize(vector<int>& arr) {
        unordered_map<int, int> mp;
        for(int num : arr)
        {
            ++mp[num];
        }

        vector<int> vt;
        for(auto& [_, e] : mp)
        {
            vt.push_back(e);
        }
        ranges::sort(vt, greater());
        for(int i = 0, sum = 0; i < vt.size(); ++i)
        {
            sum += vt[i];
            if(sum >= arr.size() / 2)
                return i + 1;
        }
        return -1;
    }
};
